package cn.momoshenchi.controller;

import cn.momoshenchi.pojo.MatchOption;
import cn.momoshenchi.service.MatchOptionService;
import cn.momoshenchi.util.ResultInfo;
import cn.momoshenchi.pojo.MatchItems;
import cn.momoshenchi.service.MatchItemsService;
import cn.momoshenchi.service.MatchUserHistoryService;
import cn.momoshenchi.vo.MatchVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @version : 1.0
 * @author: momoshenchi
 * @date: 2021/6/8 - 9:54
 */
@RestController
@RequestMapping("match")
public class MatchController
{

    @Autowired
    private MatchItemsService  matchItemsService;

    @Autowired
    private MatchUserHistoryService matchUserHistoryService;

    @Autowired
    private MatchOptionService matchOptionService;

    @GetMapping("/{size}")
    @Operation(summary = "随机返回指定数量的题目")
    public ResultInfo random(@PathVariable  Integer size)
    {
        List<MatchVo> randomTestList = matchItemsService.getRandomTestList(size);
        return  new ResultInfo(randomTestList);
    }

    @GetMapping("history/{userId}")
    @Operation(summary = "返回指定用户的答题历史")
    public ResultInfo history(@PathVariable  Integer userId)
    {
        matchUserHistoryService.getById(userId);
        return  new ResultInfo();
    }
}
